<template>
  <div class="bot-bar fz12 spaceAround">
    <div v-for="item in botList" :key="item.route" @click="goRoute(item.route)" class="bot-list">
      <!-- 使用三元运算判断图片切换 -->
      <img :src="item.route===$route.name?item.click:item.unclick" alt="" />
      <div :class="{active:item.route===$route.name}">
        {{ item.title }}
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: "bottomBar",
  data() {
    return {
      botList: [
        {
          title: "电影",
          route: "film",
          unclick: require("../../assets/images/unclick-film.png"),
          click: require("../../assets/images/click-film.png"),
        },
        {
          title: "影院",
          route: "cinema",
          unclick: require("../../assets/images/unclick-cinema.png"),
          click: require("../../assets/images/click-cinema.png"),
        },
        {
          title: "资讯",
          route: "news",
          unclick: require("../../assets/images/unclick-news.png"),
          click: require("../../assets/images/click-film.png"),
        },
        {
          title: "我的",
          route: "center",
          unclick: require("../../assets/images/unclick-me.png"),
          click: require("../../assets/images/click-me.png"),
        },
      ],
    };
  },
  methods: {
    goRoute(route) {
      this.$router.push({
        name: route,
      });
    },
  },
};
</script>

<style scoped lang="scss">
  img{
    width: 21px;
    height: 21px;
  }
  .bot-bar{
    padding: 5px 0;
  }
  .bot-list{
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
  }
  .active{
    color: #ff5f16;
  }
</style>